package com.AJava1710D.设计模式.单例;

import com.AJava1710D.设计模式.单例.懒汉式.LanHanShi;

import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * 作者: LCG
 * 日期: 2020/6/29 09:40
 * 描述:
 */
public class Test00 {

    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, IOException, ClassNotFoundException {

        //通过反射暴力访问创建对象
        /*Constructor<LanHanShi> constructor = LanHanShi.class.getDeclaredConstructor();

        constructor.setAccessible(true);

        LanHanShi lanHanShi = constructor.newInstance();

        LanHanShi instance = LanHanShi.getInstance();

        System.out.println("---->"+(lanHanShi==instance));*/


        //序列化创建对象
        /*LanHanShi instance = LanHanShi.getInstance();
        ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
        ObjectOutputStream objectOutputStream=new ObjectOutputStream(byteArrayOutputStream);

        objectOutputStream.writeObject(instance);


        ByteArrayInputStream byteArrayInputStrea=new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
        ObjectInputStream objectInputStream=new ObjectInputStream(byteArrayInputStrea);

        Object object = objectInputStream.readObject();
        System.out.println(object==instance);*/



    }

}
